{include file="public/header"/}
<div id="container">
    <div>
        <form class="layui-form" action="" style="width:500px;margin: 40px auto">
            <h4 style="margin-bottom:30px;margin-left: 60px;">客服系统微信公众号(或小程序)配置</h4>
            <div class="layui-form-item">
                <label class="layui-form-label"><b>原始id</b></label>
                <div class="layui-input-block">
                    <input type="text" name="weixin_id" required lay-verify="required" placeholder="微信公众号(或小程序)原始ID" class="layui-input" value="{$weixin_config.weixin_id}">
                </div>
            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"><b>Appid</b></label>
                <div class="layui-input-block">
                    <input type="text" name="appid" required lay-verify="required" placeholder="微信公众号开发者ID(AppID)" class="layui-input"value="{$weixin_config.appid}">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><b>Secret</b></label>
                <div class="layui-input-block">
                    <input type="text" name="secret" required lay-verify="required" placeholder="微信公众号开发者密码" class="layui-input"value="{$weixin_config.secret}">
                </div>

            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><b>Token</b></label>
                <div class="layui-input-block">
                    <input type="text" name="token" required lay-verify="required" placeholder="令牌(Token)" class="layui-input"value="{$weixin_config.token}">
                </div>

            </div>

            <div class="layui-form-item">
                <label class="layui-form-label"><b>AESKey</b></label>
                <div class="layui-input-block">
                    <input type="text" name="aes_key" placeholder="消息加解密密钥(EncodingAESKey),明文格式请留空" class="layui-input"value="{$weixin_config.aes_key}">
                </div>

            </div>

            <div class="layui-form-item">
                <div class="layui-input-block" >
                    <button class="layui-btn" lay-submit lay-filter="weixinForm">提交修改</button>
                </div>
            </div>
        </form>

        <div style="width:500px;margin:30px auto;color:#aaa;">
            <h4 style="margin-bottom:30px;margin-left: 60px;">微信公众平台基本配置</h4>
            <div class="layui-form-item">
                <label class="layui-form-label"><b>IP白名单</b></label>
                <div class="layui-form-label">
                    {$ip}
                </div>

            </div>
            <div class="layui-form-item">
                <label class="layui-form-label"><b>服务器地址(URL)</b></label>
                <div class="layui-form-label">
                    {$weixin_callback_url}
                </div>

            </div>
        </div>

        <script>
            //Demo
            layui.use('form', function(){
                var form = layui.form;
                //监听提交
                form.on('submit(weixinForm)', function(data){
                    $.ajax({
                        url: '/admin/manager/weixinSave',
                        type: 'post',
                        data: data.field,
                        dataType: 'json',
                        success: function (res) {
                            if (res.code == 0) {
                                layer.msg(res.msg, {
                                    icon: 1, end: function () {
                                        location.reload();
                                    }
                                });
                            } else {
                                layer.msg(res.msg, {icon: 2});
                            }
                        }
                    });
                    return false;
                });
            });
        </script>
    </div>
</div>

{include file="public/footer"/}
